package find;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * @author Liaorun
 */
public class FindSubvalueEqualK {

    public static void main(String[] args) {
        System.out.println(allPair(new int[]{1, 1, 3}, 2));
    }

    public static List<List<Integer>> allPair(int[] arr, int k) {
        HashSet<Integer> set = new HashSet<>();

        for (int i : arr) {
            set.add(i);
        }

        ArrayList<List<Integer>> res = new ArrayList<>();

        for (Integer cur : set) {
            if (set.contains(cur + k)) {
                res.add(Arrays.asList(cur, cur + k));
            }
        }

        return res;
    }
}
